<?php
/**
 * Created by PhpStorm.
 * User: Auser
 * Date: 2016/12/14
 * Time: 11:20
 */

namespace App\Repositories\Xjb;
use App\Models\Xjb\TestingXjbFactor;
use App\Repositories\Repository;
use Cache;
class TestingXjbFactorRepository extends Repository
{
    static $tag = 'testing.Xjb.factor';

    public function factor($tid,$index,$weight,$status){
        $cacheKey = getCacheKey('testing.cache_key.testing.xjb.factor.info');
        $cacheKey = $cacheKey.$tid.$index.$weight.$status;
        $cate = $this->remember($cacheKey, function () use ($tid,$index,$weight,$status) {
            $result = TestingXjbFactor::where('tid',$tid)
                ->where('qid',$index)
                ->where('result',$weight)
                ->where('status',$status)
                ->first();
            if($result){
                return $result;
            }else{
                return null;
            }
        });
        return $cate;
    }


    public function model()
    {
        return app(TestingXjbFactor::class);
    }

    public function tag()
    {
        return self::$tag;
    }
}